package com.sky.test;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

import java.util.concurrent.TimeUnit;

/**
 * @Description testRedis
 * @Author lijingtong
 * @Date 2024-10-07
 */

@SpringBootTest
public class testRedis {

    @Autowired
   private RedisTemplate redisTemplate;

    @Test
    public void test1(){
        ValueOperations stringOption = redisTemplate.opsForValue();
        stringOption.set("username","zhangsan");
    }


    @Test
    public void stringTest(){
        ValueOperations stringOption = redisTemplate.opsForValue();
        stringOption.set("code","6688",60, TimeUnit.SECONDS);
        Object code = stringOption.get("code");
        System.out.println(code);
    }
}
